using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;

using ILRuntime.CLR.TypeSystem;
using ILRuntime.CLR.Method;
using ILRuntime.Runtime.Enviorment;
using ILRuntime.Runtime.Intepreter;
using ILRuntime.Runtime.Stack;
using ILRuntime.Reflection;
using ILRuntime.CLR.Utils;
using System.Linq;

namespace ILRuntime.Runtime.Generated
{
    unsafe class huqiang_Unit_UnitFactory_Binding
    {
        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
        {
            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
            MethodBase method;
            FieldInfo field;
            Type[] args;
            Type type = typeof(huqiang.Unit.UnitFactory);
            args = new Type[]{typeof(System.Single)};
            method = type.GetMethod("Update", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, Update_0);
            args = new Type[]{typeof(System.String), typeof(System.String), typeof(huqiang.Unit.CollisionType)};
            method = type.GetMethod("CreateHotUnitManager", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, CreateHotUnitManager_1);
            args = new Type[]{};
            method = type.GetMethod("ClearAll", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, ClearAll_2);
            args = new Type[]{};
            method = type.GetMethod("Dispose", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, Dispose_3);

            field = type.GetField("factories", flag);
            app.RegisterCLRFieldGetter(field, get_factories_0);
            app.RegisterCLRFieldSetter(field, set_factories_0);
            app.RegisterCLRFieldBinding(field, CopyToStack_factories_0, AssignFromStack_factories_0);
            field = type.GetField("Open", flag);
            app.RegisterCLRFieldGetter(field, get_Open_1);
            app.RegisterCLRFieldSetter(field, set_Open_1);
            app.RegisterCLRFieldBinding(field, CopyToStack_Open_1, AssignFromStack_Open_1);
            field = type.GetField("managers", flag);
            app.RegisterCLRFieldGetter(field, get_managers_2);
            app.RegisterCLRFieldSetter(field, set_managers_2);
            app.RegisterCLRFieldBinding(field, CopyToStack_managers_2, AssignFromStack_managers_2);


            app.RegisterCLRCreateDefaultInstance(type, () => new huqiang.Unit.UnitFactory());
            app.RegisterCLRCreateArrayInstance(type, s => new huqiang.Unit.UnitFactory[s]);

            args = new Type[]{};
            method = type.GetConstructor(flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, Ctor_0);

        }


        static StackObject* Update_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Single @time = *(float*)&ptr_of_this_method->Value;


            huqiang.Unit.UnitFactory.Update(@time);

            return __ret;
        }

        static StackObject* CreateHotUnitManager_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 4);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            huqiang.Unit.CollisionType @collisionType = (huqiang.Unit.CollisionType)typeof(huqiang.Unit.CollisionType).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)20);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.String @shader = (System.String)typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            System.String @tex = (System.String)typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 4);
            huqiang.Unit.UnitFactory instance_of_this_method = (huqiang.Unit.UnitFactory)typeof(huqiang.Unit.UnitFactory).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.CreateHotUnitManager(@tex, @shader, @collisionType);

            object obj_result_of_this_method = result_of_this_method;
            if(obj_result_of_this_method is CrossBindingAdaptorType)
            {    
                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance);
            }
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static StackObject* ClearAll_2(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            huqiang.Unit.UnitFactory instance_of_this_method = (huqiang.Unit.UnitFactory)typeof(huqiang.Unit.UnitFactory).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.ClearAll();

            return __ret;
        }

        static StackObject* Dispose_3(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            huqiang.Unit.UnitFactory instance_of_this_method = (huqiang.Unit.UnitFactory)typeof(huqiang.Unit.UnitFactory).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.Dispose();

            return __ret;
        }


        static object get_factories_0(ref object o)
        {
            return huqiang.Unit.UnitFactory.factories;
        }

        static StackObject* CopyToStack_factories_0(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = huqiang.Unit.UnitFactory.factories;
            object obj_result_of_this_method = result_of_this_method;
            if(obj_result_of_this_method is CrossBindingAdaptorType)
            {    
                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance);
            }
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_factories_0(ref object o, object v)
        {
            huqiang.Unit.UnitFactory.factories = (System.Collections.Generic.List<huqiang.Unit.UnitFactory>)v;
        }

        static StackObject* AssignFromStack_factories_0(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.Collections.Generic.List<huqiang.Unit.UnitFactory> @factories = (System.Collections.Generic.List<huqiang.Unit.UnitFactory>)typeof(System.Collections.Generic.List<huqiang.Unit.UnitFactory>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            huqiang.Unit.UnitFactory.factories = @factories;
            return ptr_of_this_method;
        }

        static object get_Open_1(ref object o)
        {
            return huqiang.Unit.UnitFactory.Open;
        }

        static StackObject* CopyToStack_Open_1(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = huqiang.Unit.UnitFactory.Open;
            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method ? 1 : 0;
            return __ret + 1;
        }

        static void set_Open_1(ref object o, object v)
        {
            huqiang.Unit.UnitFactory.Open = (System.Boolean)v;
        }

        static StackObject* AssignFromStack_Open_1(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.Boolean @Open = ptr_of_this_method->Value == 1;
            huqiang.Unit.UnitFactory.Open = @Open;
            return ptr_of_this_method;
        }

        static object get_managers_2(ref object o)
        {
            return ((huqiang.Unit.UnitFactory)o).managers;
        }

        static StackObject* CopyToStack_managers_2(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Unit.UnitFactory)o).managers;
            object obj_result_of_this_method = result_of_this_method;
            if(obj_result_of_this_method is CrossBindingAdaptorType)
            {    
                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance);
            }
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_managers_2(ref object o, object v)
        {
            ((huqiang.Unit.UnitFactory)o).managers = (System.Collections.Generic.List<huqiang.Unit.ManagerInfo>)v;
        }

        static StackObject* AssignFromStack_managers_2(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.Collections.Generic.List<huqiang.Unit.ManagerInfo> @managers = (System.Collections.Generic.List<huqiang.Unit.ManagerInfo>)typeof(System.Collections.Generic.List<huqiang.Unit.ManagerInfo>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            ((huqiang.Unit.UnitFactory)o).managers = @managers;
            return ptr_of_this_method;
        }



        static StackObject* Ctor_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* __ret = ILIntepreter.Minus(__esp, 0);

            var result_of_this_method = new huqiang.Unit.UnitFactory();

            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }


    }
}
